package com.ruoyi.app.controller.order.mapper;

import com.ruoyi.common.core.dao.BaseMapper;
import com.ruoyi.common.entity.DO.order.MemberRechargeOrderDO;
import com.ruoyi.common.entity.VO.order.MemberRechargeOrderSearchVO;
import com.ruoyi.common.entity.VO.order.ShopOrderSearchVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

public interface IMemberRechargeOrderMapper extends BaseMapper<MemberRechargeOrderDO> {

    List<MemberRechargeOrderDO> searchList(MemberRechargeOrderSearchVO searchVO);


    @Update("UPDATE member_recharge_order SET pay_status=1,order_status=3,pay_time=sysdate() WHERE pay_sn=#{paySn}")
    int paySuccessHandle(String paySn);


    @Select("SELECT sum(amount) FROM member_recharge_order WHERE member_id=#{memberId} and pay_status=1 and order_status=3 and DATE_FORMAT(create_time, '%Y%m')=#{yearMonth} group by member_id")
    BigDecimal getTotalAmountByMonth(@Param("memberId") long memberId, @Param("yearMonth") String yearMonth);
}
